package final_wearebatman_view;

import final_wearebatman_model.Led;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;

public class LedView implements Ipaintable {

    private Led led;
    private CircuitView circuitview;
    private int posX;
    private int posY;
    private int angle;
    private String name;

    // konstrukor
    public LedView(Led l, String name, CircuitView cv, int pX, int pY, int a) {
        this.led = l;
        this.circuitview = cv;
        this.posX = pX;
        this.posY = pY;
        this.angle = a;
        this.name = name;
    }

    // kirajzolas
    public void paint(Graphics2D g) {
        AffineTransform aT = g.getTransform();
        // eltolás
        g.translate(posX, posY);
        if (this.led.getInputData(0) == 1) {
            g.setColor(Color.red);
        } else {
            g.setColor(Color.white);
        }
        g.fillOval(0, 0, 11, 11);
        g.setColor(Color.black);
        g.drawOval(0, 0, 10, 10);
        g.setTransform(aT);
    }

    public int getPosX() {
        return this.posX;
    }

    public int getPosY() {
        return this.posY;
    }

    public int getAngle() {
        return this.angle;
    }

    public Point getInputPinPosition(int id) {
        Point p = new Point(5, 5);
        AffineTransform aT = new AffineTransform();
        aT.rotate(this.angle * Math.PI / 180);
        aT.transform(p, p);
        return new Point(posX + p.x, posY + p.y);
    }

    public Point getOutputPinPosition(int id) {
        Point p = new Point(5, 5);
        AffineTransform aT = new AffineTransform();
        aT.rotate(this.angle * Math.PI / 180);
        aT.transform(p, p);
        return new Point(posX + p.x, posY + p.y);
    }

    public Rectangle getClickArea() {
        return new Rectangle();
    }

    public void onClick() {

    }
}
